<template>
	<view>
		<u-sticky bgColor="#fff">
			<u-tabs :list="list1" lineWidth="15" :scrollable="false" :activeStyle="{
		        color: '#3478f5',
		        fontWeight: 'bold',
		        transform: 'scale(1.05)'
		    }" @change="tabclick"></u-tabs>
		</u-sticky>
		<view class="mainpadding2">
			<view class="mainpadding_top ffffff radius" v-for="item in list.data" :key="item.id">
				<view class="flexbetween">
					<view class="flexleft">
						<view class="bglanlable xiaolan">{{item.subject.name}}/{{item.classname}}</view>
						<view class="titletext bold hei_text margin_left">{{item.mobile}}</view>
					</view>
					<view class="xiaohuang" v-show="item.state==1">待审核</view>
					<view class="xiaolv" v-show="item.state==2">已通过</view>
					<view class="xiaohong" v-show="item.state==3">已拒绝</view>
				</view>
				<view class="margin_top2 xiaohui">上传时间：{{item.createtime_text}}</view>
				<view class="margin_top2 xiaohui pdl" v-if="item.state!=1">处理时间：{{item.checktime_text}}</view>
				<view class="bghong xiaohong mainpadding_top radius" v-if="item.state==3">拒绝理由：{{item.error_reason}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				list1: [{
						name: "待审核",
						id: 1,
					},
					{
						name: "已通过",
						id: 2,
					},
					{
						name: "已拒绝",
						id: 3,
					}
				],
				tabsId: "1",
				page: 1,
				limit: 12,
				list: {
					data: []
				},
			}
		},
		onLoad() {
			this.init()
		},
		methods: {
			init(isPage, page) {
				let _this = this;
				httpRequest.request('/api/teacher/getmyteacherlist', 'GET', {
					page: page || 1,
					state: this.tabsId,
				}, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			tabclick(item) {
				this.tabsId = item.id
				this.init()
			},

		}
	}
</script>

<style scoped lang="scss">
	.bglanlable {
		background-color: #ebf2fe;
		border-radius: 5rpx;
		padding: 7rpx 10rpx;
	}
</style>